﻿using Compass.PurchaseService.Infrastructure;
using Compass.Wasm.Server.Services.Purchases;
using Compass.Wasm.Shared.Purchases;
using Compass.Wasm.Shared;
using System.ComponentModel.DataAnnotations;
using Compass.Wasm.Shared.Charts;

namespace Compass.Wasm.Server.Controllers.Purchases;

[Route("api/[controller]")]
[ApiController]
[UnitOfWork(typeof(PurchaseDbContext))]
public class NavInvReportClassController : ControllerBase
{
    #region ctor
    private readonly INavInvReportClassService _service;
    public NavInvReportClassController(INavInvReportClassService service)
    {
        _service = service;
    }
    #endregion

    #region 基本增删改查
    [HttpGet("All")]
    public async Task<ApiResponse<IEnumerable<NavInvReportClassDto>>> GetAll() => await _service.GetAllAsync();

    [HttpGet("{id}")]
    public async Task<ApiResponse<NavInvReportClassDto>> GetSingle([RequiredGuid] Guid id) => await _service.GetSingleAsync(id);

    [HttpPost("Add")]
    public async Task<ApiResponse<NavInvReportClassDto>> Add(NavInvReportClassDto dto) => await _service.AddAsync(dto);

    [HttpPut("{id}")]
    public async Task<ApiResponse<NavInvReportClassDto>> Update([RequiredGuid] Guid id, NavInvReportClassDto dto) => await _service.UpdateAsync(id, dto);

    [HttpDelete("{id}")]
    public async Task<ApiResponse<NavInvReportClassDto>> Delete([RequiredGuid] Guid id) => await _service.DeleteAsync(id);

    #endregion

    #region 扩展查询
    [HttpGet("Month")]
    public async Task<ApiResponse<NavInvReportClassDto>> GetSingleByMonth(DateTime month) => await _service.GetSingleByMonthAsync(month);
    //http://10.9.18.31/api/NavInvReportClass/Month?month=xxxx


    [HttpGet("Blazor/FsSubtotal")]
    public async Task<ApiResponse<IEnumerable<ChartDoubleDataDto>>> GetBlazorFsSubtotal() => await _service.GetBlazorFsSubtotalAsync();
    //http://10.9.18.31/api/NavInvReportClass/Blazor/FsSubtotal


    #endregion
}